import 'package:flutter/material.dart';
import '../MyIcon.dart';
import './tabs/Apex.dart';
import './tabs/Epic.dart';
import './tabs/GitLab.dart';
import './tabs/Steam.dart';

class Tabs extends StatefulWidget {
  const Tabs({super.key});

  @override
  State<Tabs> createState() => _TabsState();
}

class _TabsState extends State<Tabs> {
  int indexIcon = 0;
  List<Widget> list = [EpicPage(), ApexPage(), GitLabPage(), SteamPage()];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Flutter App", style: TextStyle(color: Colors.white)),
        backgroundColor: Colors.deepPurple,
      ),
      body: list[indexIcon],
      bottomNavigationBar: BottomNavigationBar(
        // 底部菜单大小
        iconSize: 30,
        // 选中颜色
        fixedColor: Colors.deepPurpleAccent,
        // 选中的第几个菜单
        currentIndex: indexIcon,
        // 底部菜单 >=4 时需要加上
        type: BottomNavigationBarType.fixed,
        onTap: (index) {
          setState(() {
            indexIcon = index;
          });
        },
        items: [
          BottomNavigationBarItem(icon: Icon(MyIcon.epic), label: "Epic"),
          BottomNavigationBarItem(icon: Icon(MyIcon.apex), label: "Apex"),
          BottomNavigationBarItem(icon: Icon(MyIcon.gitlab), label: "GitLab"),
          BottomNavigationBarItem(icon: Icon(MyIcon.steam), label: "Steam"),
        ],
      ),
    );
  }
}
